<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

    <head>
        <meta charset="UTF-8">
        <title>欢迎页面-X-admin2.2</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" th:href="@{/css/font.css}">
        <link rel="stylesheet" th:href="@{/css/login.css}">
        <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
        <link rel="stylesheet" th:href="@{/css/xadmin.css}">
        <script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
        <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
        <!--[if lt IE 9]>

        <script th:src="@{/js/html5.min.js}"></script>
        <script th:src="@{/js/responded.js}"></script>
        <![endif]-->
    </head>
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">



                  <div class="layui-form-item">
                      <label for="productId" class="layui-form-label">
                          <span class="x-red">*</span>产品编号
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="productId" name="productId" required="" lay-verify="productId"
                          autocomplete="off" class="layui-input">
                      </div>

                      <div class="layui-form-mid layui-word-aux">
                          <span class="x-red">*</span>
                      </div>
                  </div>

                  <div class="layui-form-item">
                      <label for="productName" class="layui-form-label">
                          <span class="x-red">*</span>产品名称
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="productName" name="productName" required="" lay-verify="productName"
                          autocomplete="off" class="layui-input">
                      </div>
                      <div class="layui-form-mid layui-word-aux">
                          <span class="x-red">*</span>
                      </div>
                  </div>



                  <div class="layui-form-item">
                      <label for="productType" class="layui-form-label">
                          <span class="x-red">*</span>产品类型
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="productType" name="productType" required="" lay-verify="productType"
                          autocomplete="off" class="layui-input">
                      </div>
                      <div class="layui-form-mid layui-word-aux">
                          <span class="x-red">*</span>
                      </div>
                  </div>


                    <div class="layui-form-item">
                        <label for="image" class="layui-form-label">
                            <span class="x-red">*</span>图片</label>
                        <div class="layui-input-inline">
                            <input type="text" id="image" name="image" required="" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label for="note" class="layui-form-label">
                            <span class="x-red">*</span>说明</label>
                        <div class="layui-input-inline">
                            <input type="text" id="note" name="note" required="" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label for="status" class="layui-form-label">
                            <span class="x-red">*</span>状态</label>
                        <div class="layui-input-inline">
                            <input type="text" id="status" name="status" required="" autocomplete="off" class="layui-input">
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
                    </div>


                </form>
            </div>
        </div>
        <script th:inline="javascript">
            var ctx=[[${#httpServletRequest.getContextPath()}]];


            layui.use(['form', 'layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;

                //自定义验证规则
                form.verify({

                });

                //监听提交
                form.on('submit(add)',
                    function(data) {
                        $.ajax({
                            url:ctx+"/product/add",
                            type:"POST",
                            data:data.field,

                            success:function (res) {
                                console.log(res)
                                if (res.success) {
                                    layer.alert(res.msg, {
                                            icon: 6
                                        },
                                        function () {
                                            //关闭当前frame
                                            xadmin.close();
                                            // 可以对父窗口进行刷新
                                            xadmin.father_reload();
                                        });
                                } else {
                                    layer.alert(res.msg)
                                }

                            }
                        })
                        return false;
                    });

            });
        </script>
    </body>

</html>
